package com.fyl.validation.anno;

import com.fyl.validation.RuleType;

import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(FIELD)
@Retention(RUNTIME)
@Repeatable(ValidationRule.List.class)
public @interface ValidationRule {

    String message() default "Verification failed";

    RuleType type();

    /**
     *  RuleType == REQUIRED
     *  value = boolean, eq: false or true
     *
     *  RuleType == REGULAR
     *  value = patten, eq: ^[+]{0,1}(\d+)$
     *
     * RuleType == CUSTOM
     * value = method signature, eq: com.fyl.Util.TestClass.testFun
     * @return
     */
    String value();

    @Target({FIELD})
    @Retention(RUNTIME)
    @interface List {
        ValidationRule[] value();
    }
}
